<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Installing Nagios</title>

<STYLE type="text/css">
<!--
        .Default { font-family: verdana,arial,serif; font-size: 8pt; }
        .PageTitle { font-family: verdana,arial,serif; font-size: 12pt; font-weight: bold; }
-->      
</STYLE>

</head>

<body bgcolor="#FFFFFF" text="black" class="Default">

<p>
<div align="center">
<h2 class="PageTitle">Installing Nagios</h2>
</div>
</p>
<hr>

<p>
<strong><font color='red'>Important:</font></strong> Installing and configuring Nagios is rather involved.  You can't just compile the binaries, run the program and sit back.  There's a lot to setup before you can actually start monitoring anything.  Relax, take your time and read all the documentation - you're going to need it.  Okay, let's get started...
</p>

<p>
<strong><u>Become Root</u></strong>
</p>

<p>
You'll need to have root access to install Nagios as described in this documentation, as you'll be creating users and group, modifying your web server config files, etc.  Either login as root before you begin or use the <i>su</i> command to change to the root user from another account.
</p>

<p>
<strong><u>Getting The Latest Version</u></strong>
</p>

<p>
You can download the latest version of Nagios from <a href="http://www.nagios.org/download">http://www.nagios.org/download</a>.
</p>

<p>
<strong><u>Unpacking The Distribution</u></strong>
</p>
<p>
To unpack the Nagios distribution, use the following command:
</p>
<p>
<strong>
<font color="red">
tar xzf nagios-<i>version</i>.tar.gz
</font>
</strong>
</p>
<p>
When you have finished executing these commands, you should find a <b>nagios-<i>version</i></b> directory
that has been created in your current directory.  Inside that directory you will find all the files
that comprise the core Nagios distribution.
</p>


<p>
<strong><u>Create Nagios User/Group</u></strong>
</p>

<p>
You're probably going to want to run Nagios under a normal user account, so add a new user (and group) to your system with the following command (this will vary depending on what OS you're running):
</p>
<p>
<strong>
<font color="red">
adduser nagios
</font>
</strong>
</p>

<p>
<strong><u>Create Installation Directory</u></strong>
</p>

<p>
Create the base directory where you would like to install Nagios as follows...
</p>
<p>
<p>
<strong>
<font color="red">
mkdir /usr/local/nagios
</font>
</strong>
</p>

<p>
Change the owner of the base installtion directory to be the Nagios user and group you added earlier as follows:
</p>
<p>
<strong>
<font color="red">
chown nagios.nagios /usr/local/nagios
</font>
</strong>
</p>


<p>
<strong><u>Identify Web Server User</u></strong>
</p>
<p>
You're probably going to want to issue <a href="extcommands.html">external commands</a> (like acknowledgements and scheduled downtime) from the web interface.  To do so, you need to identify the user your web server runs as (typically <i>apache</i>, although this may differ on your system).  This setting is found in your web server configuration file.  The following command can be used to quickly determine what user Apache is running as (paths may differ on your system):
</p>

<p>
<strong>
<font color="red">
grep "^User" /etc/httpd/conf/httpd.conf<br>
</font>
</strong>
</p>

<p>
<strong><u>Add Command File Group</u></strong>
</p>

<p>
Next we're going to create a new group whose members include the user your web server is running as and the user Nagios is running as.  Let's say we call this new group '<b>nagcmd</b>' (you can name it differently if you wish).  On RedHat Linux you can use the following command to add a new group (other systems may differ):
</p>

<p>
<font color="red">/usr/sbin/groupadd nagcmd</font>
</p> 

<p>
Next, add the users that your web server and Nagios run as to the newly created group with the following commands (I'll assume <i>apache</i> and <i>nagios</i> are the respective users):
</p>

<p>
<font color="red">/usr/sbin/usermod -G nagcmd apache</font><br>
<font color="red">/usr/sbin/usermod -G nagcmd nagios</font><br>
</p> 

<p>
<strong><u>Run the Configure Script</u></strong>
</p>

<p>
Run the configure script to initialize variables and create a Makefile as follows...(the last two options: --with-command-<i>xxx</i> are optional, but needed if you want to issue <a href="extcommands.html">external commands</a>)
</p>

<p>
<strong>
<font color="red">
./configure --prefix=<i>prefix</i> --with-cgiurl=<i>cgiurl</i> --with-htmurl=<i>htmurl</i> --with-nagios-user=<i>someuser</i> --with-nagios-group=<i>somegroup</i> --with-command-group=<i>cmdgroup</i>
</font>
</strong>
</p>

<p>
<ul>
<li>Replace <i>prefix</i> with the installation directory that you created in the step above (default is <i>/usr/local/nagios</i>)
<li>Replace <i>cgiurl</i> with the actual url you will be using to access the <a href="cgis.html">CGIs</a> (default is <i>/nagios/cgi-bin</i>).  Do NOT append a slash at the end of the url.
<li>Replace <i>htmurl</i> with the actual url you will be using to access the HTML for the main interface and documentation (default is <i>/nagios/</i>)
<li>Replace <i>someuser</i> with the name of a user on your system that will be used for setting permissions on the installed files (default is <i>nagios</i>)
<li>Replace <i>somegroup</i> with the name of a group on your system that will be used for setting permissions on the installed files (default is <i>nagios</i>)
<li>Replace <i>cmdgroup</i> with the name of the group running the web server (default is <i>nagios</i>, in the example above it was <i>nagcmd</i>).  This will allow group members (i.e. your web server) to be able to submit external commands to Nagios.
</ul>
</i>
</p>

<p>
<strong><u>Compile Binaries</u></strong>
</p>

<p>
Compile Nagios and the CGIs with the following command:
</p>
<p>
<strong>
<font color="red">
make all
</font>
</strong>
</p>


<p>
<a name="installing"></a>
<strong><u>Installing The Binaries And HTML Files</u></strong>
</p>

<p>
Install the binaries and HTML files (documentation and main web page) with the following command:
</p>

<p>
<strong>
<font color="red">
	make install
</font>
</strong>
</p>

<p>
<strong><u>Installing An Init Script</u></strong>
</p>

<p>
If you wish, you can also install the sample init script to <i>/etc/rc.d/init.d/nagios</i> with the following command:
</p>

<p>
<strong>
<font color="red">
	make install-init
</font>
</strong>
</p>

<p>
You may have to edit the init script to make sense with your particular OS and Nagios installation by editing paths, etc.
</p>


<p>
<a name="files"></a>
<strong><u>Directory Structure And File Locations</u></strong>
</p>

<p>
Change to the root of your Nagios installation directory with the following command...
</p>

<p>
<strong>
<font color="red">
cd /usr/local/nagios
</font>
</strong>
</p>


<p>
You should see five different subdirectories.  A brief description of what each directory contains is given in the table below.
</p>

<p>
<table border="1" class="Default">
<tr>
<td bgcolor="#cbcbcb"><strong>Sub-Directory</strong></td>
<td bgcolor="#cbcbcb"><strong>Contents</strong></td>
</tr>
<tr>
<td><strong>bin/</strong></td>
<td>Nagios core program</td>
</tr>
<tr>
<td><strong>etc/</strong></td>
<td><a href="configmain.html">Main</a>, <a href="configmain.html#resource_file">resource</a>, <a href="configobject.html">object</a>, and <a href="configcgi.html">CGI</a> configuration files should be put here</td>
</tr>
<tr>
<td><strong>sbin/</strong></td>
<td><a href="cgis.html">CGIs</a></td>
</tr>
<tr>
<td><strong>share/</strong></td>
<td>HTML files (for web interface and online documentation)</td>
</tr>
<tr>
<td><strong>var/</strong></td>
<td>Empty directory for the <a href="configmain.html#log_file">log file</a>, <a href="configmain.html#status_file">status file</a>, <a href="configmain.html#state_retention_file">retention file</a>, etc.</td>
</tr>
<tr>
<td><strong>var/archives</strong></td>
<td>Empty directory for the <a href="configmain.html#log_archive_path">archived logs</a></td>
</tr>
<tr>
<td><strong>var/rw</strong></td>
<td>Empty directory for the <a href="configmain.html#command_file">external command file</a></td>
</tr>
</table>
</p>

<p>
<strong><u>Installing The Plugins</u></strong>
</p>

<p>
In order for Nagios to be of any use to you, you're going to have to download and install some <a href="plugins.html">plugins</a>.  Plugins are usually installed in the <b>libexec/</b> directory of your Nagios installation (i.e. <i>/usr/local/nagios/libexec</i>).  Plugins are scripts or binaries which perform all the service and host checks that constitute monitoring.  You can grab the latest release of the plugins from the <a href="http://www.nagios.org/download">Nagios downloads page</a> or directly from the <a href="http://sourceforge.net/projects/nagiosplug/">SourceForge project page</a>.
</p>

<p>
<strong><u>Setup The Web Interface</u></strong>
</p>

<p>
You're probably going to want to use the web interface, so you'll also have to read the instructions on <a href="installweb.html">setting up the web interface</a> and configuring web authentication, etc. next.
</p>

<p>
<strong><u>Configuring Nagios</u></strong>
</p>

<p>
So now you have things compiled and installed, but you still haven't configured Nagios or defined objects (hosts, services, etc.) that should be monitored.  Information on configuring Nagios and defining objects can be found <a href="config.html">here</a>.  There's a lot to configure, but don't let it discourage you - its well worth it.
</p>

<hr>

</body>
</html>
